package com.baosight.sczx.common.zm.cInterface.ch;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.dao.Dao;

/**
 * 进度上报获取班组的接口
 * <p>Title: WorkSchedule.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2016</p>
 * <p>Company: Baosight Software</p>
 * @author 王伟
 * @version 1.0
 * <pre>Histroy:
 *          2016-9-1 09:26:51 王伟  Create
 *</pre>
 */

public class WorkGroup {
	
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	/**
	 * 
	 * <p>Function: getWorkScheduleBlock</p>
	 * <p>Description: </p>
	 * <p>blockId:blockId </p>
	 * <p>miningId:矿井id </p>
	 * <p>departmentId:部门id </p>
	 * <p>type:班组类型 </p>
	 * <p>return value:EiBlock</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2016-9-1 09:27:56 王伟
	 * </p>
	 *
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static EiBlock getWorkGroupBlock(String blockId,String miningId,String departmentId,String type, boolean isAll){                                                              
		EiBlock block = new EiBlock(blockId);
		
		EiColumn eiColumn = new EiColumn("value");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
				
		eiColumn = new EiColumn("display");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		List<Map>  _list = new ArrayList<Map>();
		if(isAll) {
			Map<String, String> _map = new HashMap<String, String>();
			_map.put("value", "");
			_map.put("display", "");
			_list.add(_map);
		}

		HashMap<String, String> map = new HashMap<String, String>();
		map.put("fdMiningId", miningId);
		map.put("fdDepartmentId", departmentId);
		map.put("fdType", type);
		map.put("fdIsuseFlag", "在用");
		
		List<Map> temp = dao.query("ZMCHWorkGroup.queryInterface", map);;
		for(int i = 0; i < temp.size(); i++) {
			_list.add(temp.get(i));
		}
		block.setRows(_list);
		
		return block;
	}

}
